#coding=utf-8
'''
Created on 2013-9-3

@author: Ben

世界数据
'''

import CityVO

#城市数据
cityList = {}
#是否已领取整点杀敌奖励
hourKillRewardReceived = 1

'''
初始化世界数据
'''
def init(data):
    global cityList
    global hourKillRewardReceived
    if "cities" in data:
        citiesStr = data["cities"]
        cities = citiesStr.split("#")
        for city in cities:
            if len(city) == 0:
                continue
            cityVO = CityVO.CityVO(city)
            cityList[cityVO.cityId] = cityVO
    if "received" in data:
        hourKillRewardReceived = data["received"]

'''
更新
'''
def update(data):
    global cityList
    if "cities" in data:
        if "cities" in data["cities"]:
            for city in data["cities"]["cities"]:
                if "id" in city:
                    cityId = int(city["id"])
                    cityVO = getCityVO(cityId)
                    if cityVO != None:
                        cityVO.update(city)

'''
获取城市数据
'''
def getCityVO(cityId):
    global cityList
    if cityId in cityList:
        return cityList[cityId]
    else:
        return None